<?php

/**
* UserErrorHandlerTest.php
*
* Test user error handler
*
* @author     Blazej Zieba <b@zieba.info>
* @copyright  2007 konekto.com
* @version    CVS: $Id:$
*/
require_once '../config.php';

require_once 'simpletest/autorun.php';

require_once '../UserErrorHandler.class.php';


class UserErrorHandlerTest extends UnitTestCase
{
    protected $fixture;
    protected $fileName;

    public function setUp()
    {
        $this->fileName = date("d_m_Y_h_i_s") . ".txt";
        //Make options static
        $options = &PEAR::getStaticProperty('CONFIG_INI','DEBUG');
        //Configure options 
        $options["debug"] = 0;//Don't dispaly errors
        $options["log_file"] = $this->fileName ;//Log file path
        $options['error_reporting'] = E_ALL;

        $this->fixture = new UserErrorHandler;
    }



    public function testLogFileExist()
    {
       UserErrorHandler::handler(1024, null, null, null, null);
       $this->assertTrue( file_exists( $this->fileName ) ) ;
       $content = file_get_contents( $this->fileName );
       $this->assertTrue( strpos($content,'LEAVE UserErrorHandler::userErrorHandler()') );
    }

    public function tearDown()
    {
        //Remove log file
        $this->assertTrue( unlink($this->fileName) ); 
    }
    
}


